/**
 * @author zhoutao
 *  2012-8-2
 */
package com.jlt.web.util;

import java.util.HashMap;
import java.util.Map;

public class Struts2ActionUtils {
	public static final String SUCCESSFUL = "200";
	public static final String FAILURE = "300";
	public static final String TIMEOUT = "301";

	public static final String COMM = "comm";
	public static final String SAVE = "save";
	public static final String DELETE = "delete";
	public static final String COMM_MESSAGE = "操作";
	public static final String SAVE_MESSAGE = "保存";
	public static final String DELETE_MESSAGE = "删除";

	public static final String MESSAGE_CODE = "message";
	public static final String STATUS_CODE = "statusCode";
	public static final String CALLBACK_TYPE = "callbackType";

	public static final String MESSAGE_SUCCESS = "成功！";
	public static final String MESSAGE_FAILURE = "失败！";
	public static final String MESSAGE_TIMEOUT = "超时！";

	public static final String CLOSE_CURRENT = "closeCurrent";

	public static final Map<String, String> map = new HashMap<String, String>();
	static {
		map.put(SUCCESSFUL, MESSAGE_SUCCESS);
		map.put(FAILURE, MESSAGE_FAILURE);
		map.put(TIMEOUT, MESSAGE_TIMEOUT);
		
		map.put(SAVE, SAVE_MESSAGE);
		map.put(DELETE, DELETE_MESSAGE);
		map.put(COMM, COMM_MESSAGE);
		
		map.put(CALLBACK_TYPE, CLOSE_CURRENT);
	}

	/**
	 * @author zhoutao
	 * @param String
	 *            operateType操作类型
	 * @param String
	 *            operateResult操作结果
	 * @param String
	 *            name操作名称
	 */
	public static Map<String, String> getDwzOperateMessage(String operateResult, String name) {
		Map<String, String> message = new HashMap<String, String>();
		message.put(STATUS_CODE, operateResult);
		message.put(MESSAGE_CODE, map.get(COMM) + name + map.get(operateResult));
		return message;
	}

	/**
	 * @author zhoutao
	 * @param String
	 *            operateType操作类型
	 * @param String
	 *            operateResult操作结果
	 * @param String
	 *            name操作名称
	 */
	public static Map<String, String> getDwzOperateMessage(String operateType, String operateResult, String name) {
		Map<String, String> message = new HashMap<String, String>();
		message.put(STATUS_CODE, operateResult);
		message.put(MESSAGE_CODE, map.get(operateType) + name + map.get(operateResult));
		return message;
	}

	/**
	 * @author zhoutao
	 * @param String
	 *            operateType操作类型
	 * @param String
	 *            operateResult操作结果
	 * @param String
	 *            name操作名称
	 * @param String
	 *            js回调方法
	 */
	public static Map<String, String> getDwzOperateMessage(String operateType, String operateResult, String name,
			String callbackType) {
		Map<String, String> message = new HashMap<String, String>();
		message.put(STATUS_CODE, operateResult);
		message.put(MESSAGE_CODE, map.get(operateType) + name + map.get(operateResult));
		message.put(CALLBACK_TYPE, map.get(callbackType));
		return message;
	}
}
